<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 2018/9/18
 * Time: 14:54
 */

namespace common\members\wodrow\widgets\ueditor;

use Yii;

class UEditorController extends \crazydb\ueditor\UEditorController
{
    /**
     * 各种上传
     * @param $fieldName
     * @param $config
     * @param $base64
     * @return array
     */
    protected function upload($fieldName, $config, $base64 = 'upload')
    {
        $up = new Uploader($fieldName, $config, $base64);

        if ($this->allowIntranet)
            $up->setAllowIntranet(true);

        $info = $up->getFileInfo();
        if (($this->thumbnail or $this->zoom or $this->watermark) && $info['state'] == 'SUCCESS' && in_array($info['type'], ['.png', '.jpg', '.bmp', '.gif'])) {
//            $info['thumbnail'] = Yii::$app->request->baseUrl . $this->imageHandle($info['url']);
            $info['thumbnail'] = Yii::getAlias('@storage_url') . $this->imageHandle($info['url']);
        }
//        $info['url'] = Yii::$app->request->baseUrl . $info['url'];
        $info['url'] = Yii::getAlias('@storage_url') . $info['url'];
        $info['original'] = htmlspecialchars($info['original']);
        $info['width'] = $info['height'] = 500;
        return $info;
    }
}